
function activity(t)
    -- return 1 - 0.1 * smooth_bump(t, 60, 30, 60, 30 );
    return 1;
end

-- -----------------------------------------------------------------------------
-- Na+/K+ exchanger
-- -----------------------------------------------------------------------------
NaK_info = {
    "NaK",
    { "Na+" },      -- input t,zeta,Na
    { "Na+", "K+" } -- output dNa, dK
};

K_NaK = 10e-3;

function NaK(t,zeta,Na)
    local zfac  = 0.5*(1.0+math.tanh(0.388429*( zeta - (-3.29312) )));
    local cfac = Na/(Na+K_NaK);
    local rho  =  zfac * cfac * activity(t);
    local dNa  = -3*rho;
    local dK   =  2*rho;
    return dNa,dK;
end

-- -----------------------------------------------------------------------------
-- Na+/H+ exchanger
-- -----------------------------------------------------------------------------
NHE_info = { 
    "NHE", 
    { "H+" },         -- input t,zeta,h 
    { "H+", "Na+" }   -- return dH,dNa
};

L0 = 1000;
Kr = 1.8e-8;
Kt = 3.6e-6;
C  = Kr/Kt;

function sigNHE(x)
    local xp1  = x+1;
    local Cx   = C*x;
    local Cxp1 = Cx+1;
    local num  = x*xp1 + L0*Cx*Cxp1;
    local den  = L0 * Cxp1^2 + xp1^2;
    return num/den;
end


function NHE(t,zeta,h)
    local rho = sigNHE(h/Kr) * activity(t);
    local dH  = -rho;
    local dNa =  rho;
    return dH,dNa;
end


-- -----------------------------------------------------------------------------
-- AE2 exchanger
-- -----------------------------------------------------------------------------

AE2_info =
{
    "AE2",
    { "HCO3-" }, -- input t,zeta,bicarbonate
    { "HCO3-", "Cl-"}, -- output dBicarb,dCl
};

K_AE = 10e-3;
function sigAE(x)
    return x/(K_AE+x);
end

function AE2(t,zeta,bicarb)
    local rho     =  sigAE(bicarb) * activity(t);
    local dBicarb = -rho;
    local dCl     =  rho;
    return dBicarb,dCl;
end

-- -----------------------------------------------------------------------------
-- collect effectors
-- -----------------------------------------------------------------------------
bio = {
    NHE_info,
    NaK_info,
    AE2_info
};


